/**
 * COOKIE添加数据
 * @param {string} key 键
 * @param {string} val 值
 * @param {number} t 保存时间
 */
function setCookie(key,val,t=10)
{   
    if (typeof val == "object") val = JSON.stringify(val)
    const d = new Date
    d.setTime(d.getTime()-1000*60*60*8+1000*t)
    document.cookie = `${key}=${val}; expires = ${d}`
}



/**
 * COOKIE获取数据
 * @param {string} key 键
 * @returns 
 */
function getCookie(key)
{
    let temp = document.cookie.split("; ")
    for (i=0;i<temp.length;i++)
    {
        let item = temp[i]
        let tempArr = item.split("=")
        if (tempArr[0]==key) return tempArr[1]
    }
}



/**
 * COOKIE删除数据
 * @param {string} key 键
 */
function removeCookie(key)
{
    setCookie(key,null,-1)
}